package com.jhy.config;

import cn.hutool.json.JSONUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Shardingsphere配置注入
 *
 * @author Lion Li
 */
@Order(Ordered.HIGHEST_PRECEDENCE)
public class ShardingsphereConfigPostProcessor implements EnvironmentPostProcessor {

	@Override
	public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
		Map<String, Object> map = new HashMap<>();
		map.put("spring.shardingsphere.datasource.names", "ds0,ds1");
		environment.getPropertySources().addFirst(new MapPropertySource("yaml-modifier", map));
	}


}
